From 1ecf910c9bdc713968d0e1515be865d31267619a Mon Sep 17 00:00:00 2001 From: "Lutz Dube Lutz.Dube@ts.fujitsu.com" Date: Mon, 16 Aug 2010 17:14:10 +0100 Subject: [PATCH] Values of cpu_weight and cpu_cap are lost after xend restart MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For managed domains in state 'halted' I always get default values for cpu_cap / cpu_weight after xend restart. This is because the names of parameters differ between a SXP file to create a VM (here the parameter names are cpu_cap / cpu_weight) and a SXP file of a managed VM (here vcpus_params (cap 0) (weight 0)). But XendConfig.py reads only cpu_cap / cpu_weight and if not found, default values are used.   The patch reads first vcpus_params (cap, weight), if not found then cpu_cap, cpu_weight and if both parameters are missing it uses the default values.   Signed-off-by: Lutz Dube Lutz.Dube@ts.fujitsu.com Signed-off-by: Stefano Stabellini committer: Stefano Stabellini --- tools/python/xen/xend/XendConfig.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py index 8a072955d3..cff12e89c3 100644 --- a/tools/python/xen/xend/XendConfig.py +++ b/tools/python/xen/xend/XendConfig.py @@ -686,10 +686,12 @@ class XendConfig(dict): # Convert scheduling parameters to vcpus_params if 'vcpus_params' not in cfg: cfg['vcpus_params'] = {} - cfg["vcpus_params"]["weight"] = \ - int(sxp.child_value(sxp_cfg, "cpu_weight", 256)) - cfg["vcpus_params"]["cap"] = \ - int(sxp.child_value(sxp_cfg, "cpu_cap", 0)) +        if not cfg["vcpus_params"].has_key("weight"): +            cfg["vcpus_params"]["weight"] = \ +                int(sxp.child_value(sxp_cfg, "cpu_weight", 256)) +        if not cfg["vcpus_params"].has_key("cap"): +            cfg["vcpus_params"]["cap"] = \ +                int(sxp.child_value(sxp_cfg, "cpu_cap", 0)) # Only extract options we know about. extract_keys = LEGACY_UNSUPPORTED_BY_XENAPI_CFG + \ -- 2.30.2